﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DisplayBoardInfo.Server.Entities;
using System.Threading;

namespace DisplayBoardInfo.Server.Forms.Administrator
{
    public partial class Users : CustomComponents.FormDialog
    {
        IEnumerable<Entities.User> users;

        public Users()
        {
            InitializeComponent();
        }

        private void Users_Load(object sender, EventArgs e)
        {
            
        }

        protected override void InitlializeForm()
        {

        }

        private void photo_MouseClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Image image = Image.FromFile(ofd.FileName);
                photo.Image = image;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            Entities.User user = new User();
            user.Username = username.Text;
            user.Password = password.Text;
            user.Name = name.Text;
            user.LastName = lastname.Text;
            user.Position = position.Text;
            user.RoleName = "Lekarz";
            user.Photo = photo.Image;

            user.Save();
            Cursor = Cursors.Arrow;
        }


    }
}
